package com.hundsun.cprs.yyt.service.match.core.queue;

import java.math.BigDecimal;

import com.hundsun.cprs.yyt.service.match.domain.TradeEntrust;

/**
 * 仅时间优先的订单队列，与价格无关
 * @author linrl
 * @date 2019年3月2日
 */
public class TimePriorityQueue extends PriceQueue {

    @Override
    protected boolean isPriceFavorable(long price, long compare) {
        //忽略
        return false;
    }

    @Override
    protected PriceCell getInitLeaderCell() {
        PriceCell header = new PriceCell(BigDecimal.ZERO.longValue());
        return header;
    }

    @Override
    public void placeEntrust(TradeEntrust entrust) {
        PriceCell firstCell = getHeader();
        if (firstCell == null) {
            //仅时间优先原则,与价格无关，所有仅仅头价格单元就可以
            firstCell = new PriceCell(BigDecimal.ZERO.longValue());
            this.leader.getWriteLock().lock();
            this.leader.setNext(firstCell);
            this.leader.getWriteLock().unlock();
        }
        firstCell.addEntrust(entrust);
    }
    
    
    
    

}
